package com.ruoyi.project.NH.income.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.NH.income.domain.BusiIncomeData;
import com.ruoyi.project.NH.income.service.IBusiIncomeDataService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 农户收入信息Controller
 * 
 * @author 狗熊岭
 * @date 2023-08-03
 */
@RestController
@RequestMapping("/NH/income")
public class BusiIncomeDataController extends BaseController
{
    @Autowired
    private IBusiIncomeDataService busiIncomeDataService;

    /**
     * 查询农户收入信息列表
     */
    @PreAuthorize("@ss.hasPermi('NH:income:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusiIncomeData busiIncomeData)
    {
        startPage();
        List<BusiIncomeData> list = busiIncomeDataService.selectBusiIncomeDataList(busiIncomeData);
        return getDataTable(list);
    }

    /**
     * 导出农户收入信息列表
     */
    @PreAuthorize("@ss.hasPermi('NH:income:export')")
    @Log(title = "农户收入信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiIncomeData busiIncomeData)
    {
        List<BusiIncomeData> list = busiIncomeDataService.selectBusiIncomeDataList(busiIncomeData);
        ExcelUtil<BusiIncomeData> util = new ExcelUtil<BusiIncomeData>(BusiIncomeData.class);
        util.exportExcel(response, list, "农户收入信息数据");
    }

    /**
     * 获取农户收入信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('NH:income:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(busiIncomeDataService.selectBusiIncomeDataById(id));
    }

    /**
     * 新增农户收入信息
     */
    @PreAuthorize("@ss.hasPermi('NH:income:add')")
    @Log(title = "农户收入信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusiIncomeData busiIncomeData)
    {
        return toAjax(busiIncomeDataService.insertBusiIncomeData(busiIncomeData));
    }

    /**
     * 修改农户收入信息
     */
    @PreAuthorize("@ss.hasPermi('NH:income:edit')")
    @Log(title = "农户收入信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusiIncomeData busiIncomeData)
    {
        return toAjax(busiIncomeDataService.updateBusiIncomeData(busiIncomeData));
    }

    /**
     * 删除农户收入信息
     */
    @PreAuthorize("@ss.hasPermi('NH:income:remove')")
    @Log(title = "农户收入信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(busiIncomeDataService.deleteBusiIncomeDataByIds(ids));
    }
}
